//
//  Storage.m
//  Cxzc
//
//  Created by hwd on 17/8/21.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "Storage.h"


@implementation Storage

+(void)isInJiguang//注册极光
{
    if ([ToolViewVC isNotNullStr:[Storage getToken]]) {
        NSString *jp_idStr = [NSString stringWithFormat:@"%@",[Storage getToken]];
        [JPUSHService setAlias:jp_idStr completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
        } seq:1000];
    }
}
+(void)isOutJIGuang//登出极光 替换别名
{
    [JPUSHService setAlias:@"Can" completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
    } seq:1000];
    
}
+(BOOL)isLogin//是否登录
{
    if ([standfault objectForKey:@"userInfo"]) {
        return YES;
    }
    return NO;
}

+(BOOL)isLawen//是否执法
{
    if ([[standfault objectForKey:@"lawen"] isEqualToString:@"YES"]) {
        return YES;
    }else{
        return NO;
    }
}

+(void)outLogin//退出登录
{
    [Storage isOutJIGuang];
    [standfault removeObjectForKey:@"userInfo"];
    [standfault synchronize];
}
+(NSString *)getToken//获取Id
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"id"]];
}
+(NSString *)getPhone//获取手机号码
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"mobile"]];
}
+(NSString *)getLoginName//获取登录名（后台登录）
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"loginName"]];
}
+(NSString *)getName//获取姓名
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"name"]];
}
+(NSString *)getRoleNames//获取角色
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"roleNames"]];
}
+(NSString *)getUserPhoto//获取头像
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"photo"]];
}
+(NSString *)getOfficeName//执法范围
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"officeName"]];
}
+(NSString *)getUserParentId//上一级ID
{
    return [ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"parentId"]];
}
+(NSString *)getPrinter//打印机
{
    return [ToolViewVC getNotNullStr:[standfault objectForKey:@"Printer"]];
}
+(NSString *)getUserSex//获取性别
{
    if (![ToolViewVC isNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"sex"]]) {
        return @"男";
    }
    if ([[ToolViewVC getNotNullStr:[[standfault objectForKey:@"userInfo"] objectForKey:@"sex"]] isEqual:@"0"]) {
        return @"男";
    }else{
        return @"女";
    }
}



@end
